package code.nest;

import code.nest.dto.Log;
import code.nest.util.kafka.KafkaProducerService;
import code.nest.util.kafka.impl.KafkaProceducerServiceImpl;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) throws InterruptedException {

        KafkaProducerService kafkaProducerService = new KafkaProceducerServiceImpl();
        Log errorLog = new Log(1, "这是一条错误日志", System.currentTimeMillis());
        kafkaProducerService.sendFireAndForgetMsg("log", "error", errorLog);
        Log infoLog = new Log(2, "这是一条记录日志", System.currentTimeMillis());
        kafkaProducerService.sendFutureMsg("log", "info", infoLog);
        Log debugLog = new Log(3, "这是一条调试日志", System.currentTimeMillis());
        kafkaProducerService.sendAsynMsg("log", "debug", debugLog);
        /* 如果需要异步发送的方式，这里需要sleep一下，
        发送消息的线程为守护线程，主线程结束后发送线程也会结束 */
        Thread.sleep(5000);
    }
}
